fix(#2906): resource leak on populate children #2907
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FIx for #2906
It looks like there are some situations where the explorer tries to populate a node when it is already populated. This leads to a situation in the code where the filter reason is none, however the node has already been loaded. This in turn leads to an attempt to record the hidden stats for the reason. Since the reason however is none and the
hidden_statsobject has understandably not been initialised to capture stats for reason none, the following exception is thrownError executing vim.schedule lua callback: ...r/start/nvim-tree.lua/lua/nvim-tree/explorer/explore.lua:69: attempt to perform arithmetic on a nil value stack traceback: ...r/start/nvim-tree.lua/lua/nvim-tree/explorer/explore.lua:69: in function 'populate_children'The fix changes the logic so that no attempt to record hidden stats are made and the node is not reloaded. I'm assuming here that the node has been loaded OK if the path is in the
nodes_by_pathobject. I welcome any feedback on whether that is a good assumption.